//
//  SYHoSanMingTableViewCell.m
//  SanYiTeaching
//
//  Created by 郑浩然 on 2019/6/19.
//  Copyright © 2019年 SanYi. All rights reserved.
//

#import "SYHoSanMingTableViewCell.h"
#import "SYKaoShiJuanDetailsView.h"
#import "WMPhotoBrowser.h"

@interface SYHoSanMingTableViewCell () {
    WMPhotoBrowser *browser;
    UIButton *leftBtn;
}
@property (weak, nonatomic) IBOutlet UILabel *xingmingLab;
@property (weak, nonatomic) IBOutlet UILabel *xuehaoLab;
@property (weak, nonatomic) IBOutlet UILabel *chengjiLab;
@property (weak, nonatomic) IBOutlet UILabel *mingciLab;


@end


@implementation SYHoSanMingTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setHsmModel:(SYHoSanMingModel *)hsmModel {
    _hsmModel = hsmModel;
    _xingmingLab.text = hsmModel.studentName;
    _xuehaoLab.text = hsmModel.serial;
    _chengjiLab.text = hsmModel.score;
    _mingciLab.text = hsmModel.resultOrder;
    
}
//查看试卷
- (IBAction)lookShiJuanBtnClick:(UIButton *)sender {
    [MBProgressHUD mj_showLoading];
    [SYRequestAPI yj_requeststatisticsAnsweredPaperDetailStudentId:_hsmModel.studentId templateId:_hsmModel.templateId kaoshiOrDingzheng:YES success:^(NSMutableArray *papeFilePath) {
        [MBProgressHUD mj_hideHUD];
        
        if (papeFilePath.count == 0) {
            [MBProgressHUD zr_showError:@"暂无试卷详情~！"];
            return ;
        }
//        SYKaoShiJuanDetailsView  *shidetailsView = [[SYKaoShiJuanDetailsView alloc] initWithFrame:CGRectMake(0, kScreen_HEIGHT, kScreen_WIDTH, kScreen_HEIGHT)];
//
//        UIWindow *window = [UIApplication sharedApplication].windows.firstObject;
//        [window addSubview:shidetailsView];
//
//        [UIView animateWithDuration:kAnimate animations:^{
//            shidetailsView.frame = CGRectMake(0, 0, kScreen_WIDTH, kScreen_HEIGHT);
//        } completion:^(BOOL finished) {
////            shidetailsView.pathStr = papeFilePath;
//            [shidetailsView requestDataImageArr:papeFilePath];
//        }];
        self->browser = [WMPhotoBrowser new];
        self->browser.dataSource = papeFilePath;
        self->browser.downLoadNeeded = YES;
        self->leftBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 60, 60)];
        [self->leftBtn setImage:[UIImage imageNamed:@"back_color"] forState:UIControlStateNormal];
        
        [self->leftBtn addTarget:self action:@selector(backToFirstVC:) forControlEvents:UIControlEventTouchUpInside];
        
        UIApplication *ap = [UIApplication sharedApplication];
        
        [ap.keyWindow addSubview:self->browser.view];
        [ap.keyWindow addSubview:self->leftBtn];
        
        
    } fail:^(NSError *error) {
         [MBProgressHUD mj_hideHUD];
        [XSInfoView showInfo:error.message onSubView:self];
    }];

}
-(void)backToFirstVC:(UIButton *)sender{
    [browser.view removeFromSuperview];
    [leftBtn removeFromSuperview];
}
- (IBAction)lianXiJiaZhangBtnClick:(UIButton *)sender {
//    NSMutableString* str=[[NSMutableString alloc] initWithFormat:@"%@",_hsmModel.Phone];
//    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
    
    [MBProgressHUD zr_showError:@"此功能开发中"];
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
